package lesson4;

import java.util.Scanner;

public class HomeWorkTask {

	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		
		System.out.println("Enter first number");
		long first = s.nextLong();

		System.out.println("Enter second number");
		long second = s.nextLong();
		
		//we find the number of digits in second number
		
		long delitel = 1;
		for(delitel = 1; second/delitel != 0; delitel *=10)
		{
			//do nothing here
		}
		System.out.println("delitel  = " + delitel);
		boolean exists = false;
		while(first>=delitel/10)
		{
			if((first%delitel == second) || (first < delitel && first == second))
			{
				exists = true;
				break;
			}
			else
			{
				first = first/10;
			}
		}
		
		
		System.out.println(exists ? "exists!" : "Does not exist!");
		
		
		
		
	}
}
